package com.lqjava.flowable.beans.result;
/**
 * Api统一响应格式
 * 返回obj
 * @param <T> 实体
 * @author lq 2021年3月21日 18:35:33
 */
public class ResultBean <T> {
	
	private boolean success;
	
	private String msg;
	
	private T obj;

	/**
	 * 为了代码简介 ,默认构造就是必填参数缺失
	 */
	public ResultBean(){
		this.success = false;
		this.msg = "必填参数缺失";
		this.obj = null;
	}
	
	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getObj() {
		return obj;
	}

	public void setObj(T obj) {
		this.obj = obj;
	}
	
	public void initTrue(T obj){
		this.success = true;
		this.msg = "successful";
		this.obj = obj;
	}
	
	public void initFalse(String msg){
		this.success = false;
		this.msg = msg;
		this.obj = null;
	}
	
	public static ResultBean<Object> result4Object(Object object){
		ResultBean<Object> res = new ResultBean<>();
		res.initTrue(object);
		return res;
	}
	
	public static ResultBean<String> result4String(String content){
		ResultBean<String> res = new ResultBean<>();
		res.initTrue(content);
		return res;
	}
	
}
